//
//  LTY_WKWebViewController.m
//  MooMusic
//
//  Created by 守护神 on 15/10/21.
//  Copyright © 2015年 wjy. All rights reserved.
//

#import "LTY_WKWebViewController.h"
#import <WebKit/WebKit.h>

@interface LTY_WKWebViewController ()<WKNavigationDelegate, WKUIDelegate>

@property (nonatomic, strong)WKWebView *webView;

@end

@implementation LTY_WKWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    // wkwebview值支持8.0版本之上的 6.0 7.0 不好使 不符合向下兼容
    // 初始化
    self.webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
    // 设置代理人
    self.webView.navigationDelegate = self;
    // 加到视图上
    [self.view addSubview:self.webView];
    // http://tms.xiami.com/market/music/oyasumi3.php?id=36
    // 添加网址
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.WkwebString]]];
    
    // Do any additional setup after loading the view.
}

#pragma mark - WKNavigationDelegate
// 页面开始加载时调用
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
{
    [MBProgressHUD showHUDAddedTo:self.webView animated:YES];
    
}

// 当内容开始返回时调用
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
    NSLog(@"didCommitNavigation");
    
    
}

// 页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
    NSLog(@"didFinishNavigation");
    [MBProgressHUD hideHUDForView:self.webView animated:YES];
    
}


// 页面加载失败时调用
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation
{
    NSLog(@"页面加载失败");
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
